<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div class="overlay"></div>
<button>Explore us</button>
<script>
$( "button" ).click(function() {
$( ".overlay" ).toggleClass( "transition" );
});
</script>
body{
font-family: Avenir, Helvetica, Sans-serif;
-webkit-font-smoothing: antialiased;
background: white;
}
.overlay{
background: black;
z-index: 2;
position: fixed;
top: 0%;
left: -25%;
width: 150%;
height: 100%;
transform: scaleX(0) skewX(-40deg);
transform-origin: left
}
.transition {
-webkit-animation: scaletoright 2000ms both cubic-bezier(0.770, 0.000, 0.175, 1.000);
animation: scaletoright 2000ms both cubic-bezier(0.770, 0.000, 0.175, 1.000);
}
@-webkit-keyframes scaletoright {
0% { transform: scaleX(0) skewX(-40deg); transform-origin: left; }
50% { transform: scaleX(1) skewX(0deg); transform-origin: left; }
51% { transform: scaleX(1) skewX(0deg);; transform-origin: right; }
100% { transform: scaleX(0) skewX(40deg);; transform-origin: right;}
}
button {
position: absolute;
top: 50%;
left: 50%;
transform: translateY(-50%) translateX(-50%);
border: 1px solid #000;
overflow: hidden;
color: #000;
font-size: 18px;
background: none;
cursor: pointer;
padding: 20px 80px;
display: inline-block;
outline: none;
-webkit-transition: all 0.3s cubic-bezier(0.770, 0.000, 0.175, 1.000);
-moz-transition: all 0.3s cubic-bezier(0.770, 0.000, 0.175, 1.000);
transition: all 0.3s cubic-bezier(0.770, 0.000, 0.175, 1.000);
}
button:after {
content: '';
position: absolute;
z-index: -1;
-webkit-transition: all 0.3s cubic-bezier(0.770, 0.000, 0.175, 1.000);
-moz-transition: all 0.3s cubic-bezier(0.770, 0.000, 0.175, 1.000);
transition: all 0.3s cubic-bezier(0.770, 0.000, 0.175, 1.000);
width: 0%;
height: 100%;
top: 0;
left: 0;
background: #000;
}
button:hover,
button:active {
color: white;
}
button:hover:after,
.button:active:after {
width: 100%;
}